//
//  ViewController.swift
//  AppDemo
//
//  Created by dn-56 on 2023/11/8.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var tipLabel: UILabel!
    @IBOutlet weak var textField: UITextField!

    @IBOutlet weak var textField2: UITextField!
    @IBOutlet weak var button1: UIButton!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        self.textField.text = "video_154771"
        self.textField2.text = "mp4"

    }
    @IBAction func buttonAction2(_ sender: UIButton) {
        let vc = TableViewController()
        vc.action = { str in
            let array = str.components(separatedBy: ".")
            if let first = array.first,let last = array.last{
                self.textField.text = first
                self.textField2.text = last
            }
        }
        self.present(vc, animated: true, completion: nil)
    }
    @IBAction func buttonAction1(_ sender: Any) {
        
        let startTime = Date().timeIntervalSince1970
        debugPrint("视频开始操作 = ",startTime)
        guard let playUrl = Bundle.main.path(forResource:"\(self.textField.text!)", ofType:"\(self.textField2.text!)") else { return }
        let viewUrl = URL(fileURLWithPath: playUrl)
        LivePhoto17.livePhotoGenerate(viewUrl) {
            DispatchQueue.main.async {
                debugPrint("视频总耗时 = ",(Date().timeIntervalSince1970 - startTime))
                self.tipLabel.text = "视频总耗时 = \((Date().timeIntervalSince1970 - startTime))"
            }
        } failure: {
            DispatchQueue.main.async {
                debugPrint("视频总耗时 = ",(Date().timeIntervalSince1970 - startTime))
                self.tipLabel.text = "失败"
            }
        }
    }
    
    func startAction(_ first :String,_ last :String){
        
    }
}

